/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package apus.action;

import apus.entity.PhoneNumber;
import apus.persistence.AccountDAO;
import apus.persistence.PhoneNumberDAO;
import apus.services.ServiceLocator;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author 21vek
 */
public class PaidAction implements Action{

    @Override
    public String getName() {
        return "paid";
    }

    @Override
    public ActionResult execute(HttpServletRequest request, HttpServletResponse response) {
        ServiceLocator.getService(AccountDAO.class).payAccount(Integer.parseInt(request.getParameter("accountId")));
        List<PhoneNumber> phoneNumberList = ServiceLocator.getService(PhoneNumberDAO.class).findAll();
       // request.setAttribute("phoneNumberList", phoneNumberList);
        request.getSession().setAttribute("win", "Payment is successfully carried out");
        return ActionResult.redirect("main.view");
    }
    
}
